﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

public class EraseFade : MonoBehaviour {

    public static EraseFade Instance;
    public Animator fadeAni;
    public bool canTouch = false;
    public AudioClip EraseClip;
    public AudioClip Pass;

    [HideInInspector]
    public AudioSource audios;

	// Use this for initialization
	void Start ()
    {
        Instance = this;
        audios = GameObject.Find("Main Camera").GetComponent<AudioSource>();
	}
	
    void Fade()
    {
        fadeAni.speed = 0;
    }

    void FadeLast()
    {
        GameObject.Find("Canvas").SendMessage("Level2Last");
    }

	// Update is called once per frame
	void Update ()
    {
        
        //if(Input.touchCount==1)
        //{
        //    if (Input.touches[0].phase == TouchPhase.Moved)
        //    {
        //        float x = Input.GetAxis("Mouse X");
        //        float y = Input.GetAxis("Mouse Y");
        //        if (x>0.1f || y>0.1f)
        //        {
        //            image.DOFade(this.image.color.a - 0.1f, 1);
        //        }   
        //    } 
        //}

        if (Input.GetMouseButton(0) && canTouch==true)
        {
            audios.clip = EraseClip;
            audios.Play();
            audios.loop = false;

            if (fadeAni.enabled==false)
            {
                fadeAni.enabled = true;
            }
            else
            {
                fadeAni.speed = 1;
            }
        }
    }
}
